using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Net;
using System.Runtime.CompilerServices;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Threading;
namespace Microsoft.Phone.Controls.Maps.PlatformServices
{
	[GeneratedCode("System.ServiceModel", "4.0.0.0"), DebuggerStepThrough]
	internal class ImageryServiceClient : ClientBase<IImageryService>, IImageryService
	{
		private class ImageryServiceClientChannel : ClientBase<IImageryService>.ChannelBase<IImageryService>, IImageryService
		{
			public ImageryServiceClientChannel(ClientBase<IImageryService> client) : base(client)
			{
			}
			public IAsyncResult BeginGetImageryMetadata(ImageryMetadataRequest request, AsyncCallback callback, object asyncState)
			{
				return base.BeginInvoke("GetImageryMetadata", new object[]
				{
					request
				}, callback, asyncState);
			}
			public ImageryMetadataResponse EndGetImageryMetadata(IAsyncResult result)
			{
				object[] array = new object[0];
				return (ImageryMetadataResponse)base.EndInvoke("GetImageryMetadata", array, result);
			}
			public IAsyncResult BeginGetMapUri(MapUriRequest request, AsyncCallback callback, object asyncState)
			{
				return base.BeginInvoke("GetMapUri", new object[]
				{
					request
				}, callback, asyncState);
			}
			public MapUriResponse EndGetMapUri(IAsyncResult result)
			{
				object[] array = new object[0];
				return (MapUriResponse)base.EndInvoke("GetMapUri", array, result);
			}
		}
		private ClientBase<IImageryService>.BeginOperationDelegate onBeginGetImageryMetadataDelegate;
		private ClientBase<IImageryService>.EndOperationDelegate onEndGetImageryMetadataDelegate;
		private SendOrPostCallback onGetImageryMetadataCompletedDelegate;
		private ClientBase<IImageryService>.BeginOperationDelegate onBeginGetMapUriDelegate;
		private ClientBase<IImageryService>.EndOperationDelegate onEndGetMapUriDelegate;
		private SendOrPostCallback onGetMapUriCompletedDelegate;
		private ClientBase<IImageryService>.BeginOperationDelegate onBeginOpenDelegate;
		private ClientBase<IImageryService>.EndOperationDelegate onEndOpenDelegate;
		private SendOrPostCallback onOpenCompletedDelegate;
		private ClientBase<IImageryService>.BeginOperationDelegate onBeginCloseDelegate;
		private ClientBase<IImageryService>.EndOperationDelegate onEndCloseDelegate;
		private SendOrPostCallback onCloseCompletedDelegate;
		public event EventHandler<GetImageryMetadataCompletedEventArgs> GetImageryMetadataCompleted
		{
			[MethodImpl(32)]
			add
			{
				this.GetImageryMetadataCompleted = (EventHandler<GetImageryMetadataCompletedEventArgs>)Delegate.Combine(this.GetImageryMetadataCompleted, value);
			}
			[MethodImpl(32)]
			remove
			{
				this.GetImageryMetadataCompleted = (EventHandler<GetImageryMetadataCompletedEventArgs>)Delegate.Remove(this.GetImageryMetadataCompleted, value);
			}
		}
		public event EventHandler<GetMapUriCompletedEventArgs> GetMapUriCompleted
		{
			[MethodImpl(32)]
			add
			{
				this.GetMapUriCompleted = (EventHandler<GetMapUriCompletedEventArgs>)Delegate.Combine(this.GetMapUriCompleted, value);
			}
			[MethodImpl(32)]
			remove
			{
				this.GetMapUriCompleted = (EventHandler<GetMapUriCompletedEventArgs>)Delegate.Remove(this.GetMapUriCompleted, value);
			}
		}
		public event EventHandler<AsyncCompletedEventArgs> OpenCompleted
		{
			[MethodImpl(32)]
			add
			{
				this.OpenCompleted = (EventHandler<AsyncCompletedEventArgs>)Delegate.Combine(this.OpenCompleted, value);
			}
			[MethodImpl(32)]
			remove
			{
				this.OpenCompleted = (EventHandler<AsyncCompletedEventArgs>)Delegate.Remove(this.OpenCompleted, value);
			}
		}
		public event EventHandler<AsyncCompletedEventArgs> CloseCompleted
		{
			[MethodImpl(32)]
			add
			{
				this.CloseCompleted = (EventHandler<AsyncCompletedEventArgs>)Delegate.Combine(this.CloseCompleted, value);
			}
			[MethodImpl(32)]
			remove
			{
				this.CloseCompleted = (EventHandler<AsyncCompletedEventArgs>)Delegate.Remove(this.CloseCompleted, value);
			}
		}
		public CookieContainer CookieContainer
		{
			get
			{
				IHttpCookieContainerManager property = base.get_InnerChannel().GetProperty<IHttpCookieContainerManager>();
				if (property != null)
				{
					return property.get_CookieContainer();
				}
				return null;
			}
			set
			{
				IHttpCookieContainerManager property = base.get_InnerChannel().GetProperty<IHttpCookieContainerManager>();
				if (property == null)
				{
					throw new InvalidOperationException("Unable to set the CookieContainer. Please make sure the binding contains an HttpCookieContainerBindingElement.");
				}
				property.set_CookieContainer(value);
			}
		}
		public ImageryServiceClient()
		{
		}
		public ImageryServiceClient(string endpointConfigurationName) : base(endpointConfigurationName)
		{
		}
		public ImageryServiceClient(string endpointConfigurationName, string remoteAddress) : base(endpointConfigurationName, remoteAddress)
		{
		}
		public ImageryServiceClient(string endpointConfigurationName, EndpointAddress remoteAddress) : base(endpointConfigurationName, remoteAddress)
		{
		}
		public ImageryServiceClient(Binding binding, EndpointAddress remoteAddress) : base(binding, remoteAddress)
		{
		}
		[EditorBrowsable]
		IAsyncResult IImageryService.BeginGetImageryMetadata(ImageryMetadataRequest request, AsyncCallback callback, object asyncState)
		{
			return base.get_Channel().BeginGetImageryMetadata(request, callback, asyncState);
		}
		[EditorBrowsable]
		ImageryMetadataResponse IImageryService.EndGetImageryMetadata(IAsyncResult result)
		{
			return base.get_Channel().EndGetImageryMetadata(result);
		}
		private IAsyncResult OnBeginGetImageryMetadata(object[] inValues, AsyncCallback callback, object asyncState)
		{
			ImageryMetadataRequest request = (ImageryMetadataRequest)inValues[0];
			return ((IImageryService)this).BeginGetImageryMetadata(request, callback, asyncState);
		}
		private object[] OnEndGetImageryMetadata(IAsyncResult result)
		{
			ImageryMetadataResponse imageryMetadataResponse = ((IImageryService)this).EndGetImageryMetadata(result);
			return new object[]
			{
				imageryMetadataResponse
			};
		}
		private void OnGetImageryMetadataCompleted(object state)
		{
			if (this.GetImageryMetadataCompleted != null)
			{
				ClientBase<IImageryService>.InvokeAsyncCompletedEventArgs invokeAsyncCompletedEventArgs = (ClientBase<IImageryService>.InvokeAsyncCompletedEventArgs)state;
				this.GetImageryMetadataCompleted.Invoke(this, new GetImageryMetadataCompletedEventArgs(invokeAsyncCompletedEventArgs.get_Results(), invokeAsyncCompletedEventArgs.get_Error(), invokeAsyncCompletedEventArgs.get_Cancelled(), invokeAsyncCompletedEventArgs.get_UserState()));
			}
		}
		public void GetImageryMetadataAsync(ImageryMetadataRequest request)
		{
			this.GetImageryMetadataAsync(request, null);
		}
		public void GetImageryMetadataAsync(ImageryMetadataRequest request, object userState)
		{
			if (this.onBeginGetImageryMetadataDelegate == null)
			{
				this.onBeginGetImageryMetadataDelegate = new ClientBase<IImageryService>.BeginOperationDelegate(this.OnBeginGetImageryMetadata);
			}
			if (this.onEndGetImageryMetadataDelegate == null)
			{
				this.onEndGetImageryMetadataDelegate = new ClientBase<IImageryService>.EndOperationDelegate(this.OnEndGetImageryMetadata);
			}
			if (this.onGetImageryMetadataCompletedDelegate == null)
			{
				this.onGetImageryMetadataCompletedDelegate = new SendOrPostCallback(this.OnGetImageryMetadataCompleted);
			}
			base.InvokeAsync(this.onBeginGetImageryMetadataDelegate, new object[]
			{
				request
			}, this.onEndGetImageryMetadataDelegate, this.onGetImageryMetadataCompletedDelegate, userState);
		}
		[EditorBrowsable]
		IAsyncResult IImageryService.BeginGetMapUri(MapUriRequest request, AsyncCallback callback, object asyncState)
		{
			return base.get_Channel().BeginGetMapUri(request, callback, asyncState);
		}
		[EditorBrowsable]
		MapUriResponse IImageryService.EndGetMapUri(IAsyncResult result)
		{
			return base.get_Channel().EndGetMapUri(result);
		}
		private IAsyncResult OnBeginGetMapUri(object[] inValues, AsyncCallback callback, object asyncState)
		{
			MapUriRequest request = (MapUriRequest)inValues[0];
			return ((IImageryService)this).BeginGetMapUri(request, callback, asyncState);
		}
		private object[] OnEndGetMapUri(IAsyncResult result)
		{
			MapUriResponse mapUriResponse = ((IImageryService)this).EndGetMapUri(result);
			return new object[]
			{
				mapUriResponse
			};
		}
		private void OnGetMapUriCompleted(object state)
		{
			if (this.GetMapUriCompleted != null)
			{
				ClientBase<IImageryService>.InvokeAsyncCompletedEventArgs invokeAsyncCompletedEventArgs = (ClientBase<IImageryService>.InvokeAsyncCompletedEventArgs)state;
				this.GetMapUriCompleted.Invoke(this, new GetMapUriCompletedEventArgs(invokeAsyncCompletedEventArgs.get_Results(), invokeAsyncCompletedEventArgs.get_Error(), invokeAsyncCompletedEventArgs.get_Cancelled(), invokeAsyncCompletedEventArgs.get_UserState()));
			}
		}
		public void GetMapUriAsync(MapUriRequest request)
		{
			this.GetMapUriAsync(request, null);
		}
		public void GetMapUriAsync(MapUriRequest request, object userState)
		{
			if (this.onBeginGetMapUriDelegate == null)
			{
				this.onBeginGetMapUriDelegate = new ClientBase<IImageryService>.BeginOperationDelegate(this.OnBeginGetMapUri);
			}
			if (this.onEndGetMapUriDelegate == null)
			{
				this.onEndGetMapUriDelegate = new ClientBase<IImageryService>.EndOperationDelegate(this.OnEndGetMapUri);
			}
			if (this.onGetMapUriCompletedDelegate == null)
			{
				this.onGetMapUriCompletedDelegate = new SendOrPostCallback(this.OnGetMapUriCompleted);
			}
			base.InvokeAsync(this.onBeginGetMapUriDelegate, new object[]
			{
				request
			}, this.onEndGetMapUriDelegate, this.onGetMapUriCompletedDelegate, userState);
		}
		private IAsyncResult OnBeginOpen(object[] inValues, AsyncCallback callback, object asyncState)
		{
			return this.BeginOpen(callback, asyncState);
		}
		private object[] OnEndOpen(IAsyncResult result)
		{
			this.EndOpen(result);
			return null;
		}
		private void OnOpenCompleted(object state)
		{
			if (this.OpenCompleted != null)
			{
				ClientBase<IImageryService>.InvokeAsyncCompletedEventArgs invokeAsyncCompletedEventArgs = (ClientBase<IImageryService>.InvokeAsyncCompletedEventArgs)state;
				this.OpenCompleted.Invoke(this, new AsyncCompletedEventArgs(invokeAsyncCompletedEventArgs.get_Error(), invokeAsyncCompletedEventArgs.get_Cancelled(), invokeAsyncCompletedEventArgs.get_UserState()));
			}
		}
		public void OpenAsync()
		{
			this.OpenAsync(null);
		}
		public void OpenAsync(object userState)
		{
			if (this.onBeginOpenDelegate == null)
			{
				this.onBeginOpenDelegate = new ClientBase<IImageryService>.BeginOperationDelegate(this.OnBeginOpen);
			}
			if (this.onEndOpenDelegate == null)
			{
				this.onEndOpenDelegate = new ClientBase<IImageryService>.EndOperationDelegate(this.OnEndOpen);
			}
			if (this.onOpenCompletedDelegate == null)
			{
				this.onOpenCompletedDelegate = new SendOrPostCallback(this.OnOpenCompleted);
			}
			base.InvokeAsync(this.onBeginOpenDelegate, null, this.onEndOpenDelegate, this.onOpenCompletedDelegate, userState);
		}
		private IAsyncResult OnBeginClose(object[] inValues, AsyncCallback callback, object asyncState)
		{
			return this.BeginClose(callback, asyncState);
		}
		private object[] OnEndClose(IAsyncResult result)
		{
			this.EndClose(result);
			return null;
		}
		private void OnCloseCompleted(object state)
		{
			if (this.CloseCompleted != null)
			{
				ClientBase<IImageryService>.InvokeAsyncCompletedEventArgs invokeAsyncCompletedEventArgs = (ClientBase<IImageryService>.InvokeAsyncCompletedEventArgs)state;
				this.CloseCompleted.Invoke(this, new AsyncCompletedEventArgs(invokeAsyncCompletedEventArgs.get_Error(), invokeAsyncCompletedEventArgs.get_Cancelled(), invokeAsyncCompletedEventArgs.get_UserState()));
			}
		}
		public void CloseAsync()
		{
			this.CloseAsync(null);
		}
		public void CloseAsync(object userState)
		{
			if (this.onBeginCloseDelegate == null)
			{
				this.onBeginCloseDelegate = new ClientBase<IImageryService>.BeginOperationDelegate(this.OnBeginClose);
			}
			if (this.onEndCloseDelegate == null)
			{
				this.onEndCloseDelegate = new ClientBase<IImageryService>.EndOperationDelegate(this.OnEndClose);
			}
			if (this.onCloseCompletedDelegate == null)
			{
				this.onCloseCompletedDelegate = new SendOrPostCallback(this.OnCloseCompleted);
			}
			base.InvokeAsync(this.onBeginCloseDelegate, null, this.onEndCloseDelegate, this.onCloseCompletedDelegate, userState);
		}
		protected override IImageryService CreateChannel()
		{
			return new ImageryServiceClient.ImageryServiceClientChannel(this);
		}
	}
}
